import 'package:flutter/material.dart';
import 'package:sample2/components/notification/chat_event.dart';
import 'package:sample2/helper/chat_helper.dart';
import 'package:sample2/model/chat/chat_constants.dart';
import 'package:sample2/model/chat/chat_user.dart';
import 'package:sample2/model/user_info.dart';

class ChatProfile extends StatefulWidget {
  const ChatProfile({super.key});
  @override
  State<StatefulWidget> createState() {
    return ChatProfileState();
  }
}

class ChatProfileState extends State<ChatProfile> {
  late ChatPeerStatus? currentStatus = ChatPeerStatus.offline;
  String statusDesc = "--";
  @override
  void initState() {
    ChatHelper.getCurrentUser().then((ChatUser? chatUser) {
      chatUser?.getStatusDesc();
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return NotificationListener(
      child: Scaffold(
        appBar: AppBar(title: const Text("Profile")),
        body: ListView(
          children: [Text(statusDesc), const Text("profile")],
        ),
      ),
      onNotification: (ChatEvent notification) {
        if (notification.chatEventKind == ChatEventKind.chatEventEnterSystem) {
          statusDesc = "Online";
        }
        return true;
      },
    );
  }
}
